home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_qt.idb / usr / freeware / include / Qt / qpaintdevice.h.z / qpaintdevice.h
Encoding:
C/C++ Source or Header  |  1998-10-28  |  5.2 KB  |  186 lines

  1. /****************************************************************************
  2. ** $Id: qpaintdevice.h,v 2.8 1998/07/03 00:09:35 hanord Exp $
  3. **
  4. ** Definition of QPaintDevice class
  5. **
  6. ** Created : 940721
  7. **
  8. ** Copyright (C) 1992-1998 Troll Tech AS.  All rights reserved.
  9. **
  10. ** This file is part of Qt Free Edition, version 1.40.
  11. **
  12. ** See the file LICENSE included in the distribution for the usage
  13. ** and distribution terms, or http://www.troll.no/free-license.html.
  14. **
  15. ** IMPORTANT NOTE: You may NOT copy this file or any part of it into
  16. ** your own programs or libraries.
  17. **
  18. ** Please see http://www.troll.no/pricing.html for information about 
  19. ** Qt Professional Edition, which is this same library but with a
  20. ** license which allows creation of commercial/proprietary software.
  21. **
  22. *****************************************************************************/
  23.  
  24. #ifndef QPAINTDEVICE_H
  25. #define QPAINTDEVICE_H
  26.  
  27. #ifndef QT_H
  28. #include "qwindowdefs.h"
  29. #include "qrect.h"
  30. #endif // QT_H
  31.  
  32.  
  33. // Painter device types (is-A)
  34.  
  35. #define PDT_UNDEF    0x00
  36. #define PDT_WIDGET    0x01
  37. #define PDT_PIXMAP    0x02
  38. #define PDT_PRINTER    0x03
  39. #define PDT_PICTURE    0x04
  40. #define PDT_MASK    0x0f
  41.  
  42.  
  43. // Painter device flags
  44.  
  45. #define PDF_EXTDEV    0x10
  46. #define PDF_PAINTACTIVE 0x20
  47.  
  48.  
  49. // Painter device command param (defined in qpaintdevicedefs.h)
  50.  
  51. union QPDevCmdParam;
  52.  
  53.  
  54. class QPaintDevice                // device for QPainter
  55. {
  56. public:
  57.     virtual ~QPaintDevice();
  58.  
  59.     int         devType()          const;
  60.     bool     isExtDev()          const;
  61.     bool     paintingActive() const;
  62.  
  63.     // Windows:      get device context
  64.     // OS/2 PM:      get presentation space
  65.     // X-Windows: get drawable
  66.     HANDLE   handle()  const;
  67.  
  68. #if !defined(_WS_X11_)
  69. #define Display void
  70. #endif
  71.     Display *x11Display() const;        // X11 only
  72.  
  73. #if defined(_WS_X11_)
  74.     static Display *x__Display();
  75.     static int        x11Screen();
  76.     static int        x11Depth();
  77.     static int        x11Cells();
  78.     static HANDLE   x11Colormap();
  79.     static bool        x11DefaultColormap();
  80.     static void       *x11Visual();
  81.     static bool        x11DefaultVisual();
  82. #endif
  83.  
  84. protected:
  85.     QPaintDevice( uint devflags );
  86.  
  87. #if defined(_WS_WIN_)
  88.     HDC         hdc;                // device context
  89. #elif defined(_WS_PM_)
  90.     HPS         hps;                // presentation space
  91. #elif defined(_WS_X11_)
  92.     static Display *dpy;            // display (common to all)
  93.     HANDLE   hd;                // handle to drawable
  94. #endif
  95.  
  96.     virtual bool cmd( int, QPainter *, QPDevCmdParam * );
  97.     virtual int     metric( int ) const;
  98.     virtual int     fontMet( QFont *, int, const char * = 0, int = 0 ) const;
  99.     virtual int     fontInf( QFont *, int ) const;
  100.  
  101.     uint     devFlags;                // device flags
  102.  
  103.     friend class QColor;
  104.     friend class QPainter;
  105.     friend class QPaintDeviceMetrics;
  106.     friend void bitBlt( QPaintDevice *, int, int, const QPaintDevice *,
  107.             int, int, int, int, RasterOp, bool );
  108.  
  109. #if defined(_WS_X11_)
  110. private:
  111.     static Display *x_display;
  112.     static int        x_screen;
  113.     static int        x_depth;
  114.     static int        x_cells;
  115.     static HANDLE   x_colormap;
  116.     static bool        x_defcmap;
  117.     static void       *x_visual;
  118.     static bool     x_defvisual;
  119. #endif
  120.  
  121. private:    // Disabled copy constructor and operator=
  122.     QPaintDevice( const QPaintDevice & );
  123.     QPaintDevice &operator=( const QPaintDevice & );
  124. };
  125.  
  126.  
  127. void bitBlt( QPaintDevice *dst, int dx, int dy,
  128.          const QPaintDevice *src, int sx=0, int sy=0, int sw=-1, int sh=-1,
  129.          RasterOp = CopyROP, bool ignoreMask=FALSE );
  130.  
  131. void bitBlt( QPaintDevice *dst, int dx, int dy,
  132.          const QImage *src, int sx=0, int sy=0, int sw=-1, int sh=-1,
  133.          int conversion_flags=0 );
  134.  
  135.  
  136. /*****************************************************************************
  137.   Inline functions
  138.  *****************************************************************************/
  139.  
  140. inline int QPaintDevice::devType() const
  141. { return devFlags & PDT_MASK; }
  142.  
  143. inline bool QPaintDevice::isExtDev() const
  144. { return (devFlags & PDF_EXTDEV) != 0; }
  145.  
  146. inline bool QPaintDevice::paintingActive() const
  147. { return (devFlags & PDF_PAINTACTIVE) != 0; }
  148.  
  149. #if defined(_WS_WIN_)
  150. inline HANDLE    QPaintDevice::handle()    const { return hdc; }
  151. #elif defined(_WS_PM_)
  152. inline HANDLE    QPaintDevice::handle()    const { return hps; }
  153. #elif defined(_WS_X11_)
  154. inline HANDLE    QPaintDevice::handle()    const { return hd; }
  155. #endif
  156.  
  157. #if defined(_WS_X11_)
  158. inline Display *QPaintDevice::x11Display() const { return dpy; }
  159. #else
  160. inline Display *QPaintDevice::x11Display() const { return 0; }
  161. #undef Display
  162. #endif
  163.  
  164. #if defined(_WS_X11_)
  165. inline Display *QPaintDevice::x__Display()       { return x_display; }
  166. inline int    QPaintDevice::x11Screen()       { return x_screen; }
  167. inline int    QPaintDevice::x11Depth()       { return x_depth; }
  168. inline int    QPaintDevice::x11Cells()       { return x_cells; }
  169. inline HANDLE    QPaintDevice::x11Colormap()       { return x_colormap; }
  170. inline bool        QPaintDevice::x11DefaultColormap() { return x_defcmap; }
  171. inline void    *QPaintDevice::x11Visual()       { return x_visual; }
  172. inline bool        QPaintDevice::x11DefaultVisual()   { return x_defvisual; }
  173. #endif
  174.  
  175.  
  176. inline void bitBlt( QPaintDevice *dst, const QPoint &dp,
  177.             const QPaintDevice *src, const QRect &sr =QRect(0,0,-1,-1),
  178.             RasterOp rop=CopyROP, bool ignoreMask=FALSE )
  179. {
  180.     bitBlt( dst, dp.x(), dp.y(), src, sr.x(), sr.y(), sr.width(), sr.height(),
  181.         rop, ignoreMask );
  182. }
  183.  
  184.  
  185. #endif // QPAINTDEVICE_H
  186.